package com.zito.health.controller;

import com.zito.health.common.annotations.ResponseResult;
import com.zito.health.entity.Role;
import com.zito.health.service.RoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by gan on 2019/11/4.
 */
@Slf4j
@ResponseResult
@RestController
@RequestMapping("/role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    /**
     *
     * @param type 0 admin 1实验室
     * @return
     */
    @GetMapping("/{type}")
    public List<Role> list(@PathVariable Integer type){
        List<Role> list = new ArrayList<Role>();
        if(type == 0){//0 admin 1实验室
            list = roleService.query(null);
        }else{//0 admin 1实验室
            Role role = new Role();
            role.setRoleid(9);//9实验室单位管理员,这个地方写死了
            list = roleService.query(role);
        }
        return list;
    }

    @PostMapping("/{roleids}")
//    public List<Role> list4Admin(@PathVariable String roleids){
        public List<Role> list4Admin( @PathVariable String roleids){
        List<Role> list = new ArrayList<Role>();
        list =roleService.list4Admin(roleids);

        return list;
    }



}
